 define(function(require,exports,module){
	
	require('common');
    require('qd-auth-1.0');
	var Animate = require('/plugins/extend/Animate');

	$('#changePassword').click(function(){
		var oldpassword=$('#oldpassword').val();
		var password=$('#password').val();
		if(oldpassword==password){
			$('#password').next('span').find('em').html("新密码不能和原密码相同！");
			return false;
		}
	});

	var emailcode=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	$('#getNewMailVcode').click(function(){
		if(!emailcode.test($('#email').val())&&($('#email').val()!='')){
			$("#modifyEmailForm")[0].reset();
			return false;
		}
	});

	var urlAction = window.location.search.substr(3);
	//重置交易密码
	if(urlAction == 'resetPayPwd'){
		$("#modifyPayPwdBtn").addClass("setting_btn_selected");
		$("#modifyPayPwdForm").hide();
		$("#modifyPayPwdBox").show();
		$("#getCodeForpayPwd").show();
	}
	//修改密码
	if(urlAction == 'modifyPwd'){
		$("#modifyPwdBtn").addClass("setting_btn_selected");
		$("#modifyPwdBox").show();
	}
	$("#forgetPayPwd").click(function(){
		$("#modifyPayPwdForm").hide();
		$("#getCodeForpayPwd").show();
		$.ajax({
			url:"/user/messageTimeCheck.html",
			type:"post",
			success:function(data){
				var remain = data.remain;
				if(remain!=undefined&&remain!=0){
					wait = remain;
					get_code_time($("#getPaypwdCode")[0]);
					
				}
			}
		});
	});
	
	$("#bindPhone").click(function(){
		$("#modifyPhoneBtn").trigger("click");
	});
	
	//按钮倒计时
	var wait = 60;
	var timeCount = 0;
	get_code_time = function (o) {
		if (wait == 0) {
			o.removeAttribute("disabled");
			o.value = "重新发送";
			wait = 60;
		} else {
			o.setAttribute("disabled", true);
			o.value = "(" + wait + ")秒后重新获取";
			wait--;
			timeCount = setTimeout(function() {
				get_code_time(o);
			}, 1000);
		}
	};		
	
	//-S-密保问题初始化
	function questionFun(){
		var option1,option2,option3,option4,option5,option6,option7;
		option1 = '<option value="您母亲的姓名是？" data-value="_string">您母亲的姓名是？</option>';
		option2 = '<option value="您父亲的姓名是？" data-value="_string">您父亲的姓名是？</option>';
		option3 = '<option value="您配偶的姓名是？" data-value="_string">您配偶的姓名是？</option>';
		option4 = '<option value="您的出生地是？" data-value="_string">您的出生地是？</option>';
		option5 = '<option value="您父亲的生日是？" data-value="_number">您父亲的生日是？</option>';
		option6 = '<option value="您母亲的生日是？" data-value="_number">您母亲的生日是？</option>';
		option7 = '<option value="您配偶的生日是？" data-value="_number">您配偶的生日是？</option>';
		
		var options = option1+option2+option3+option4+option5+option6+option7;
		
		var objBox = $("select");
		var valued = [],itemVal = "";
		var itemOption,optionVal;
		objBox.each(function(){
			$(this).append(options);
		});
		objBox.bind("change" ,function(){
			var that = $(this);
			valued.push(that.val());//获取到所有select的value
			if(valued.length>3){
				valued.shift();
			}
			itemVal = valued.join("？");
			itemOption = $("option",objBox);
			itemOption.each(function(i){
				optionVal = $(itemOption[i]).attr("value");
				if(itemVal.match(optionVal)){
					$(itemOption[i]).hide();
				}else{
					$(itemOption[i]).show();
				}
			});
		});
	}
	//questionFun();
	//-E-密保问题初始化
	
	function formSubmit(form,callBack){
		$(form).find("input").trigger("blur");		
		$(form).ajaxSubmit({
			dataType:'json',
			success:function(data){

				if(data.result){
					if(typeof callBack == "function"){
						callBack.call(this);
					}					
				} else {
                    var errorCode = data.err_code || "";
                    if(errorCode === "E0001")
                    {
                        $.showDialogNeedLogin("您的帐户已在其它地方登录!如非本人操作请及时修改密码!");
                    } else {                       	                        	
                    	layerTip(form,1,{msg:data.msg});                       	                           
                    }
				}
			}
		});
	}
	
	//1失败提示，2成功提示, 3等待提示
	function layerTip(form,type,options,SucCallBack){
		var html = "";
		if(type==1){
			html = '<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont errIco">&#xe63e;</i><span>'+options.msg+'</span></div><div class="tipsBtnBar"><a href="javascript:;" class="okBtn failBtn">确定</a></div></div>';                                       	
		}else if(type==2){
			html = '<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont okIco">&#xe63d;</i><span>'+options.msg+'</span></div><div class="tipsMsg">3秒后窗口自动关闭</div></div>';
		}else if(type==3){
			html = '<div id="tips"><div class="tipsWrap w384"><div class="tipsTxt"><span>'+options.msg+'</span></div></div></div>';
		}	
		
		if(options.closeBtn==undefined){
			options.closeBtn = 1;
		}
		
		layer.open({
             type: 1,
             closeBtn:options.closeBtn,
             time:options.time||0,
             title: "&nbsp;",
             area: ['384px', '186px'],
             border: [1, 1, '#cecfd0'],
             content:html,
             cancel: function (index) {
                 if(type==1){
                	 layer.closeAll();
                     $(form)[0].reset();
                 }else if(type==2||type==3){
                	 window.location.reload();
                 }           	 
             },
             end: function(){
            	 if(type==2||type==3){
            		 window.location.reload();
            	 }
             },
             success:function(layero){
            	 if(type==2){
	            	 var time =3; 
			    	 function closeTime () {
						 time--;
						 $(".tipsMsg").html(time+"秒后窗口自动关闭");
					 }
			    	 setInterval(function() {
			    		 closeTime();
			    	 }, 1000);
            	 }
             }
         });
		 $(".failBtn").unbind('click').click(function(){
             layer.closeAll();
             $(form)[0].reset();
         });
	}	
	
	$("#modifyVerificationBtn2").click(function(){
		$.ajax({
			type:"get",
			url:"/tpp/tppAction/realName.html?tppVerifyType=MOBILE",
			dataType:"json",
			success:function(json){
				if(json.result==true){
					layerTip("",2,{time:3000,msg:"实名认证成功"});
				}else{
					layerTip("",3,{msg:json.msg});
				}
			}
		});	
	});
	
	//-S 实名认证，公司开户认证
	$("#modifyVerificationForm").validate({
		rules:{
			companyName:{
				required:true,
				rangelength:[4,50]
			},
			website:{
				required:true,
				url:true
			},
			address:{
				required:true,
				rangelength:[5,50]
			},
			licenseNo:{
				required:true,
				licenseno:true
			},
			licenseAddress:{
				required:true,
				rangelength:[5,50]
			},
			licenseExpireDate:{
				required:true
			},
			businessScope:{
				required:true,
				rangelength:[5,100]
			},
			telephone:{
				required:true,
				fixNumber:true
			},
			email:{
				required:true,
				email:true
			},
			organizationNo:{
				required:true,
				organizationNo:true
			},
			summary:{
				required:true,
				rangelength:[5,100]
			},
			legalPerson:{
				required:true,
				rangelength:[2,25],
				chnName:true
			},
			certNo:{
				required:true,
				isIdCardNo:true,
				remote:{
					type: "get",
					url: "/tpp/tppSinaAction/checkCertNo.html",
					data:{
						certNo: function(){
							return $("#certNo").val();
						}
					}
				}
			},
			legalPersonPhone:{
				required:true,
				isMobile:true,
				remote:{
					type: "get",
					url: "/tpp/tppSinaAction/checkLegalPersonPhone.html",
					data:{
						legalPersonPhone: function(){
							return $("#legalPersonPhone").val();
						}
					}
				}
			},
			bankAccountNo:{
				required:true,
				rangelength:[15,19]
			},
			comfirmAccount:{
				required:true,
				equalTo: "#infoyhzh"
			},
			realName:{
				required:true,
				chnName:true
			},
			cardId:{
				required:true,
				isIdCardNo:true,
				remote:{
					type: "get",
					url: "/user/checkCardId.html",
					data:{
						cardId: function(){
							return $("#cardId").val();
						}
					}
				}
			},
			cardPositive:{
				required:true
			},
			cardOpposite:{
				required:true
			},
			file:{
				required:true
			}
		},
		messages:{
			companyName:{
				required:"公司名称不能为空",
				rangelength:"请正确输入公司名称"
			},
			website:{
				required:"企业网址不可为空",
				url: "请输入正确的网址"
			},
			address:{
				required:"企业地址不可为空",
				rangelength:"地址长度必须大于{0}且包含中文"
			},
			licenseNo:{
				required:"执照号不能为空"
			},
			licenseAddress:{
				required:"所在地不可为空",
				rangelength:"地址长度必须大于{0}且包含中文"
			},
			startTime:{
				required:"营业期限不能为空"
			},
			businessScope:{
				required:"营业范围不可为空",
				rangelength:"请填写{0}个字以上"
			},
			telephone:{
				required:"联系电话不可为空",
				fixNumber:"请输入正确的联系电话"
			},
			email:{
				required:"邮箱地址不可为空",
				email:"请输入正确的邮箱地址"
			},
			organizationNo:{
				required:"组织机构不可为空"
			},
			summary:{
				required:"企业简介不可为空",
				rangelength:"描述需在{0}个字级以上"
			},
			legalPerson:{
				required:"企业法人不能为空",
				rangelength:"且输入正确长度的名称",
				chnName:"请输入中文名称"
			},
			certNo:{
				required:"法人身份证号不可为空",
				isIdCardNo:"请输入正确身份证号",
				remote:"该法人证件号码已经存在"
			},
			legalPersonPhone:{
				required:"手机号码不能为空",
				remote:"该法人手机号码已经存在"
			},
			bankAccountNo:{
				required:"请输入银行账号",
				rangelength:"请输入{0}~{1}位银行账号"
			},
			comfirmAccount:{
				required:"确认银行账号",
				equalTo:"两次输入的银行卡不一致，请重新输入"
			},
			file:{
				required:"请上传企业资质文件"
			},
			realName:{
				required:"请输入真实姓名",
				chnName:"真实姓名仅为中文"
			},
			cardId:{
				required:"请输入二代身份证号码",
				isIdCardNo:"请正确输入您的身份证号码",
				remote:"身份证号码已存在"
			}
		},
		errorElement:'em',
		errorPlacement:function(error,element){
			element.parents("li").find("span").html(error);
	    },
	    success:function(label){
	    	$(form).submit();
	    },  
	    submitHandler:function(form){
//	    	$(form).find("input").trigger("blur");
//	    	layerTip(form,3,{msg:"实名认证中，请稍等",closeBtn:0});
//	    	
//	    	$(form).ajaxSubmit({
//				dataType:'json',
//				success:function(data){
//					if(data.result){
//						$("#tips").html('<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont okIco">&#xe63d;</i><span>实名认证申请成功</span></div><div class="tipsBtnBar"><a href="javascript:;" id="okBtn" class="okBtn">确定</a></div></div>');
//						$("#okBtn").unbind('click').click(function(){
//							window.location = "/member/tpp/loanAuthorize.html";
//						});
//					}else {
//	                    var errorCode = data.err_code || "";
//	                    if(errorCode === "E0001")
//	                    {
//	                        $.showDialogNeedLogin("您的帐户已在其它地方登录!如非本人操作请及时修改密码!");
//	                    }else if(data.errCode == "2" || data.errCode == 2){ 
//	                    	$("#smrzErrorForm")[0].reset();
//	                    	var smrzCid = $("#modifyVerificationForm").find("input[name='cardId']").val();
//	                    	var smrzRname = $("#modifyVerificationForm").find("input[name='realName']").val();
//	                    	$("#smrzErrorForm").find("input[name='cardId']").val(smrzCid);
//	                    	$("#smrzErrorForm").find("input[name='realName']").val(smrzRname);
//	                    	
//	                    	window.layer.open({
//	                			type: 1,
//	                			closeBtn: 1,
//	                	        title: "绑定账号",
//	                			area: ['450px', '200px'],
//	                			border: [1, 1, '#cecfd0'],
//	                			content: $("#smrzErrorWin")
//	                		});	
//	                    }else {
//	                        $("#tips").html('<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont errIco">&#xe63e;</i><span>'+data.msg+'</span></div><div class="tipsBtnBar"><a href="javascript:;" id="okBtn" class="okBtn">确定</a></div></div>');
//	                        $("#okBtn").unbind('click').click(function(){
//	                            window.location.reload();
//	                        });
//	                    }
//					}
//				}
//			});

        } 
	});
	//-E 公司开户认证
	$("#smrzErrorWinBtn1").click(function(){
		var _that = this;
		$.ajax({
			url:"/tpp/tppAction/sendRealNameCode.html",
			success:function(data){
				if(data.result==true){
					get_code_time(_that);
					
				}else{
					layer.alert(data.msg);
				}
				
			}
		});
	});
	$("#smrzErrorForm").validate({
		rules:{
			bindCode:{
				required:true
			}
		},
		messages:{
			bindCode:{
				required:"请填写验证码"
			}
		},
		errorElement:'em',
		errorPlacement:function(error,element){
			element.next().next().html(error);
	    },
	    submitHandler:function(form){			
	    	$(form).ajaxSubmit({
				dataType:'json',
				success:function(data){
					if(data.msg==undefined){
						data.msg = "实名认证失败";
					}
					if(data.result){
						window.location = "/member/tpp/loanAuthorize.html";  	
					} else {
	                    layer.alert(data.msg);
					}
				}
			});
	    } 
	});
	//-S 邮箱获取验证码
	$("#mailValidata").validate({
		rules:{
			code:{
				required:true
			}
		},
		messages:{
			code:{
				required: "请输入验证码"
			}
		},
		errorElement:'em',
		errorPlacement:function(error,element){
			if(element.hasClass("setting_vtxt")){
				element.next().next().html(error);
			}else{
				element.next().html(error);
			}
	    },
	    success:function(label){
	    },  
	    submitHandler:function(form){			
			formSubmit(form,function(){
				$("#modifyEmailForm").show();
				$("#mailValidata").hide();
				clearTimeout(timeCount);	    				
				wait = 60;
			});			
	    } 
	});
	//-E 邮箱获取验证码
		
	
	//-S 修改邮箱
	$("#modifyEmailForm").validate({
		rules:{
			email:{
				required:true,
				email:true,
				remote:{
					type: "get",
					url: "/user/checkEmail.html",
					data:{
						email: function(){
							return $("#email").val();
						}
					}
				}
			}
		},
		messages:{
			email:{
				required:"请输入新邮箱",
				email:"邮箱格式有误,请输入正确邮箱",
				remote:"邮箱地址已经存在"
			}
		},
		errorElement:'em',
		errorPlacement:function(error,element){
			if(element.hasClass("setting_vtxt")){
				element.next().next().html(error);
			}else{
				element.next().html(error);
			}
	    },
	    success:function(data){},
	    submitHandler:function(form){
	    	formSubmit(form,function(){
	    		layerTip(form,2,{time:3000,msg:"邮箱绑定成功"}); 
			});
	    	
        } 
	});
	//-E 修改邮箱
	
	//-S 短信获取验证码
	$("#mobilePhoneValidata").validate({
		rules:{
			code:{
				required:true
			}
		},
		messages:{
			code:{
				required: "请输入验证码"
			}
		},
		errorElement:'em',
		errorPlacement:function(error,element){
			if(element.hasClass("setting_vtxt")){
				element.next().next().html(error);
			}else{
				element.next().html(error);
			}
	    },
	    success:function(label){
	    },  
	    submitHandler:function(form){
	    	formSubmit(form,function(){
	    		$("#modifyPhoneForm1").removeClass("hide");
				$("#mobilePhoneValidata").addClass("hide");
			});
	    	
        } 
	});
	//-E 短信获取验证码
	
	//-S 绑定手机
	$("#modifyPhoneForm").validate({
		rules:{
			mobilePhone:{
				required:true,
				isMobile:true,
				remote:{
					type: "get",
					url: "/user/checkMobilePhone.html",
					data:{
						mobilePhone: function(){
							return $("#mobilePhone").val();
						}
					}
				}
			},
			code:{
				required:true
			}
		},
		messages:{
			mobilePhone:{
				required:"请输入手机号码",
				isMobile:"请填写正确的手机号码",
				remote:"该手机号码已存在"
			},
			code:{
				required: "请输入验证码"
			}
		},
		errorElement:'em',
		errorPlacement:function(error,element){
			if(element.hasClass("setting_vtxt")){
				element.next().next().html(error);
			}else{
				element.next().html(error);
			}
	    },
	    success:function(label){
	    },  
	    submitHandler:function(form){
	    	formSubmit(form,function(){
	    		layerTip(form,2,{time:3000,msg:"手机绑定成功"});	
			});
	    	//$(".setting_vtxt").val("");
	    	//放置在layerTip(form,1,{msg:data.msg})之后; 
	    } 
	});
	//-E 绑定手机
	
	//-S 修改手机
	$("#modifyPhoneForm1").validate({
		rules:{
			mobilePhone:{
				required:true,
				isMobile:true,
				remote:{
					type: "get",
					url: "/user/checkMobilePhone.html",
					data:{
						mobilePhone: function(){
							return $("#mobilePhone").val();
						}
					}
				}
			},
			code:{
				required:true
			}
		},
		messages:{
			mobilePhone:{
				required:"请输入手机号码",
				isMobile:"请填写正确的手机号码",
				remote:"该手机号码已存在"
			},
			code:{
				required: "请输入验证码"
			}
		},
		errorElement:'em',
		errorPlacement:function(error,element){
			if(element.hasClass("setting_vtxt")){
				element.next().next().html(error);
			}else{
				element.next().html(error);
			}
	    },
	    success:function(label){
	    },  
	    submitHandler:function(form){
			$(form).find("input").trigger("blur");
			$(form).ajaxSubmit({
				dataType:'json',
				success:function(data){
					require.async('common1',function(msgBox){
						if(data.result){
							msgBox.messageBox(1,"手机号码修改成功！","/member/security/setting.html");
    					} else {
                            var errorCode = data.err_code || "";
                            if(errorCode === "E0001")
                            {
                                $.showDialogNeedLogin("您的帐户已在其它地方登录!如非本人操作请及时修改密码!");
                            } else {
                                msgBox.messageBox(2, data.msg, "/member/security/setting.html");
                                $(".setting_vtxt").val("");
                            }
    					}
					});
				}
			});
	    } 
	});
	//-E 修改手机
	//-S登录密码修改验证
	$("#modifyPwdForm").validate({
		rules:{
			newPwd:{
				required:true,
				regexPassword:true
			},
			confirmNewPwd:{
				required:true,
				equalTo: "#password"
			}
		},
		messages:{
			pwd:{
				required:"请输入原密码",
				regexPassword:"原密码格式错误"
			},
			newPwd:{
				required: "至少8到16位英文和数字",
				regexPassword:'新密码格式错误'
			},
			confirmNewPwd: {
				required: "请再输一次新密码",
				equalTo: "两次密码不一致"
			  }
		},
		errorElement:'em',
		errorPlacement:function(error,element){
			element.next().html(error);
	    },
	    success:function(label){
	    },  
	    submitHandler:function(form){
	    	formSubmit(form,function(){
	    		layerTip(form,2,{time:3000,msg:"登录密码修改成功"});
			});	    	
        } 
	});

	//-E登录密码修改验证
	
	//-S交易密码验证
	$("#modifyPayPwdForm").validate({
		rules:{
			payPwd:{
				required:true,
				regexPassword:true
			},
			newPayPwd:{
				required:true,
				regexPassword:true
			},
			confirmNewPayPwd:{
				required:true,
				equalTo: "#pay_password"
			}
		},
		messages:{
			payPwd:{
				required:"请输入原密码",
				regexPassword:"原密码格式错误"
			},
			newPayPwd:{
				required: "至少8到16位英文和数字",
				regexPassword:'新密码格式错误'
			},
			confirmNewPayPwd: {
				required: "请再输一次新密码",
				equalTo: "两次密码不一致"
			  }
		},
		errorElement:'em',
		errorPlacement:function(error,element){
			element.next().html(error);
	    },
	    success:function(label){
	    },
	    submitHandler:function(form){
	    	formSubmit(form,function(){
	    		layerTip(form,2,{time:3000,msg:"交易密码设置成功"});
			});	    	
        }
	});
	//-E交易密码验证

	//-S 重置交易密码
	$("#getCodeForpayPwd").validate({
		rules:{
			code:{
				required:true
			},
			newPayPwd:{
				required:true,
				regexPassword:true
			},
			confirmNewPayPwd:{
				required:true,
				equalTo: "#confirmNewPayPwd"
			}
		},
		messages:{
			code:{
				required: "请输入验证码"
			},
			newPayPwd:{
				required: "至少8到16位英文和数字",
				regexPassword:'新密码格式错误'
			},
			confirmNewPayPwd: {
				required: "请再输一次新密码",
				equalTo: "两次密码不一致"
			}
		},
		errorElement:'em',
		errorPlacement:function(error,element){
			if(element.hasClass("setting_vtxt")){
				element.next().next().html(error);
			}else{
				element.next().html(error);
			}
		},
		success:function(label){
		},
		submitHandler:function(form){
			formSubmit(form,function(){
	    		layerTip(form,2,{time:3000,msg:"交易密码设置成功"});
			});	
			
		}
	});
	//-E 重置交易密码
	
	//-S密保问题验证
	$("#modifyQuestionForm").validate({
		rules:{
			answer1:{
				required:true
			},
			answer2:{
				required:true
			},
			answer3:{
				required:true
			}
		},
		messages:{
			answer1:{
				required:"请输入问题一答案"
			},
			answer2:{
				required: "请输入问题二答案"
			},
			answer3: {
				required: "请输入问题三答案"
			  }
		},
		errorElement:'em',
		errorPlacement:function(error,element){
			element.next().html(error);
	    },
	    success:function(label){
	    },  
	    submitHandler:function(form){
	    	formSubmit(form,function(){
	    		layerTip(form,2,{time:3000,msg:"密保问题修改成功"});
			});		    	
        } 
	});
	//-E密保问题验证
	
	
	//获取邮箱验证码
	$("#getMailVcode").click(function(){
		var o = this;
		$.ajax({
			url:'/member/security/modifyEmailCode.html?randomTime=' + (new Date()).getTime(),
			type:'post',
            dataType:'json',
			success:function(data){
				if(data.result){
					get_code_time(o);
				} else {
                    var errorCode = data.err_code || "";
                    if(errorCode === "E0001")
                    {
                        $.showDialogNeedLogin("您的帐户已在其它地方登录!如非本人操作请及时修改密码!");
                    }
                }
			}
		});
	});
	
	
	$("#getNewMailVcode").click(function(){
		var o = this;
		if($('#email').val()!="" ){
			//判断邮箱是否存在
			$.ajax({
				url: "/user/checkEmail.html?randomTime=" + (new Date()).getTime(),
				type:'post',
				data:{email:$("#email").val()},
				success:function(data){
					if(data){
						$.ajax({
							url:'/member/security/bindEmailCode.html?email=' + $('#email').val() + '&randomTime=' + (new Date()).getTime(),
							type:'post',
							success:function(data){
								if(data.result){
									get_code_time(o);
								} else {
                                    var errorCode = data.err_code || "";
                                    if(errorCode === "E0001")
                                    {
                                        $.showDialogNeedLogin("您的帐户已在其它地方登录!如非本人操作请及时修改密码!");
                                    }
                                }
							}
						});
					} else {
                        var errorCode = data.err_code || "";
                        if(errorCode === "E0001")
                        {
                            $.showDialogNeedLogin("您的帐户已在其它地方登录!如非本人操作请及时修改密码!");
                        } else {
                        	layerTip(form,1,{msg:"该邮箱地址已存在"});                      	                      	
                            return false;
                        }
					}
				}
			});		
		} else {
			layerTip(form,1,{msg:"请输入新邮箱"}); 			
			return false;
		}
	});


     //绑定手机时，获取验证码
     $("#getPhoneVcode").click(function () {
         var o = this;
         var mobile = /^1[3|4|5|7|8][0-9]{9}$/;
         if ($("#mobilePhone").val != "") {
             $.ajax({
                 type: "get",
                 url: "/user/checkMobilePhone.html?randomTime=" + (new Date()).getTime(),
                 data: {mobilePhone: $("#mobilePhone").val()},
                 success: function (data) {
                     if (data) {
                         if ($('#mobilePhone').val() != "" && mobile.test($('#mobilePhone').val())) {
                             $.ajax({
                                 url: '/member/security/bindPhoneCode.html?mobilePhone=' + $('#mobilePhone').val() + '&randomTime=' + (new Date()).getTime(),
                                 type: 'post',
                                 success: function (data) {
                                     if (data.result) {
                                         get_code_time(o);
                                     } else {
                                         var errorCode = data.err_code || "";
                                         if (errorCode === "E0001") {
                                             $.showDialogNeedLogin("您的帐户已在其它地方登录!如非本人操作请及时修改密码!");
                                         }
                                     }
                                 }
                             });
                         } else {                           
                             layerTip(form,1,{msg:"请输入正确的手机号码"});
                             return false;
                         }
                     } else {
                         var errorCode = data.err_code || "";
                         if (errorCode === "E0001") {
                             $.showDialogNeedLogin("您的帐户已在其它地方登录!如非本人操作请及时修改密码!");
                         }
                     }
                 }
             });
         }
     });
	
	//修改手机，获取验证码
	$("#getHavePhoneVcode").click(function(){
		var o = this;
			$.ajax({
				url:'/member/security/modifyPhoneCode.html?randomTime=' + (new Date()).getTime(),
				type:'post',
				dataType: 'json', 
				success:function(data){
					if(data.result){
						get_code_time(o); 
					} else {
                        var errorCode = data.err_code || "";
                        if (errorCode === "E0001") {
                            $.showDialogNeedLogin("您的帐户已在其它地方登录!如非本人操作请及时修改密码!");
                        }
                    }
				}
			});
	});

	//重置交易密码，获取验证码
	$("#getPaypwdCode").click(function(){
		var o = this;
		$.ajax({
			url:'/member/security/getPaypwdCode.html?randomTime=' + (new Date()).getTime(),
			type:'post',
			dataType: 'json', 
			success:function(data){
				if(data.result){
					get_code_time(o); 
				} else {
                    var errorCode = data.err_code || "";
                    if (errorCode === "E0001") {
                        $.showDialogNeedLogin("您的帐户已在其它地方登录!如非本人操作请及时修改密码!");
                    }
                }
			}
		});
	});

	//手风琴切换效果
	require.async('commonJS/jquery.accordion',function(){
		$(".setting dd").accordion({
			wrapBox    : ".setting",//最外围wrap元素
			titleBox   : ".setting_btn",//显示的标题
			contentBox : ".setting_form",//隐藏的内容
			hoverClass : "setting_btn_selected",//展示之后的样式
			isClick    : true  //默认点击展开
		});
	});
	
	
	$("#gotoReal").click(function(){
		$("#modifyVerificationBtn").trigger("click");
	});
	
	$("#gotoPhone").click(function(){
		$("#modifyPhoneBtn").trigger("click");
	});
	
	$("#gotoMail").click(function(){
		$("#modifyEmailBtn").trigger("click");
	});
	
	$("#gotoPayPwd").click(function(){
		$("#modifyPayPwdBtn").trigger("click");
	});
	

	//加载城市选择插件
	require.async('jquery-citySelect/jquery.cityselect',function(){
		$("#city").citySelect({
			url:"../../../themes/theme_default/media/js/jquery-citySelect/city.json",
			prov:"浙江", //省份 
			city:"杭州", //城市 
			dist:"西湖区", //区县 
		    required:true,
		    nodata:"none" //当子集无数据时，隐藏select 
		});
	});
	
	$("#file").change(function(){
		var filepath = this.value;
		var filename = filepath.replace(/^.+?\\([^\\]+?)(\.[^\.\\]*?)?$/gi, "$1");
		var filetype = filepath.replace(/.+\./,"");
		document.getElementById('viewfile').value=filepath;
		document.getElementById('mfileName').value=filename;
		this.style.display='none';
	});
});
